package com.teach;

/**
 * <pre>
 * - 业务的异常消息 
 * Author : J.L.Zhou
 * E-Mail : 2233875735@qq.com
 * Tel : 151 1104 7708
 * Date : 2021-5-26 11:57:43
 * Version : 1.0
 * Copyright 2021 jlzhou.top Inc. All rights reserved.
 * Warning: this content is only for internal circulation of the company.
 *          It is forbidden to divulge it or use it for other commercial purposes.
 * </pre>
 */
public class CodeException extends RuntimeException {

	private static final long serialVersionUID = 1L;

	/**
	 * - 异常编号
	 */
	private int code;

	/**
	 * - 异常消息
	 */
	private String message;

	public CodeException(int code) {
		super("code." + code);
		this.code = code;
	}

	public CodeException(int code, String message) {
		super(message);
		this.code = code;
	}

	public CodeException(int code, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
		super("code." + code, cause, enableSuppression, writableStackTrace);
		this.code = code;
	}

	public CodeException(int code, String message, Throwable cause, boolean enableSuppression,
			boolean writableStackTrace) {
		super(message, cause, enableSuppression, writableStackTrace);
		this.code = code;
	}

	public CodeException(int code, Throwable cause) {
		super("code." + code, cause);
		this.code = code;
	}

	public CodeException(int code, String message, Throwable cause) {
		super(message, cause);
		this.code = code;
	}

	public int getCode() {
		return code;
	}

	public String getMessage() {
		return message == null ? super.getMessage() : message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	@Override
	public String getLocalizedMessage() {
		return super.getLocalizedMessage();
	}

	@Override
	public synchronized Throwable getCause() {
		return super.getCause();
	}

	@Override
	public StackTraceElement[] getStackTrace() {
		return super.getStackTrace();
	}

}
